<?php
/**
 * creater: phuongtt
 * date: 23/09/2011
 * Class Xu ly thong thong tin loai danh muc
 */
class user_IndexController extends  Zend_Controller_Action {
	public function init(){
		//Load cau hinh thu muc trong file config.ini
        $tempDirApp = Zend_Registry::get('conDirApp');
		$this->_dirApp = $tempDirApp->toArray();
		$this->view->dirApp = $tempDirApp->toArray();		
		//Cau hinh cho Zend_layoutasdfsdfsd
		Zend_Layout::startMvc(array(
			    'layoutPath' => $this->_dirApp['layout'],
			    'layout' => 'hideleft'			    
			    ));	
		
		//Lay duong dan thu muc goc (path directory root)
		$this->view->baseUrl = $this->_request->getBaseUrl() . "/public/";
		Zend_Loader::loadClass('user_modUser');
		$sGetValueInCookie = Efy_Library::_getCookie("showHideMenu");
		if ($sGetValueInCookie == "" || is_null($sGetValueInCookie) || !isset($sGetValueInCookie)){
			Efy_Library::_createCookie("showHideMenu",1);
			$this->view->hideDisplayMeneLeft = 1;
		}else{//Da ton tai Cookie
			if ($sGetValueInCookie != 0){
				$this->view->hideDisplayMeneLeft = 1;
			}else{
				$this->view->hideDisplayMeneLeft = "";
			}
		}
	}	
	public function changepassAction(){
		$objFunction = New Efy_Function_RecordFunctions();
		$objModel = new user_modUser();
		$ojbEfyInitConfig = new Efy_Init_Config();	
		$oldPass = $this->_request->getParam('txtOldpass','');
		$newPass = $this->_request->getParam('txtNewpass','');
		$action = $this->_request->getParam('hdnaction','');
		$urlback = $this->_request->getParam('urlback','');
		$this->view->urlback = $urlback;
		if ($action == 'changepass'){
			$sRetError = $objModel->QLGDClassUpdate($_SESSION['staff_id'],md5($oldPass),md5($newPass));
			if($sRetError != null || $sRetError != '' ){
				if ($sRetError == '1')
					$strError = 'Mật khẩu cũ không đúng, vui lòng thử lại!';
				echo "<script type='text/javascript'>alert('$strError')</script>";
			}
			else 
				echo "<script type='text/javascript'>alert('Mật khẩu của bạn đã được thay đổi thành công!');window.location='".$urlback."';</script>";
		}	
	}
}
?>